package fizzpicks.tetrapulp.tetrapulp;

import java.util.Set;
import java.util.EnumSet;

/**
 * This data structure stores the entire game state passed onto the Lockjaw engine.
 */
public class LJField {
    /* Game state */
    public int[][] b = new int[Lockjaw.LJ_PF_HT][Lockjaw.LJ_PF_WID];
    public int[][] c = new int[Lockjaw.LJ_PF_HT][Lockjaw.LJ_PF_WID];
    public LJBits clearedLines = new LJBits();
    public Set<LJSND> sounds = EnumSet.noneOf(LJSND.class);
    public LJBits tempRows = new LJBits();
    public LJP[] curPiece = new LJP[1 + Lockjaw.LJ_NEXT_PIECES];
    public LJP[] permuPiece = new LJP[2 * Lockjaw.MAX_BAG_LEN];
    public int permuPhase;
    public short[] nLineClears = new short[Lockjaw.LJ_MAX_LINES_PER_PIECE];  // [n-1] = # of n-line clears
    public long y;
    public LJState state;
    public int stateTime;
    public int theta;
    public int x;
    public int hardDropY;
    public boolean alreadyHeld;
    public IsSpin isSpin;
    public byte nLinesThisPiece;
    public boolean canRotate;
    public int upwardKicks;

    /* Persist from piece to piece */
    public int score, lines;
    public long gameTime;  // number of frames
    public long activeTime;  // number of frames
    public LJP holdPiece;
    public boolean chain;
    public int garbage;
    public int dropDist;
    public int garbageX;
    public int nPieces, outGarbage;

    /* Determined by gimmick */
    public LJGM gimmick;
    public int bpmCounter;
    public long speedupCounter;
    public long goalCount;
    public long seed;
    public int goalType;

    public LJSpeedSetting speed = new LJSpeedSetting();
    public SpeedStateBase speedState = new SpeedStateBase();

    public LJLOCK lockReset;  // lockdown reset rule type
    public int areStyle;
    public byte setLockDelay;  // Overridden lock delay (255 = never)
    public byte setLineDelay;  // Overridden line delay
    public LJGARBAGE garbageStyle = LJGARBAGE.NONE;
    public int ceiling;
    public boolean enterAbove;
    public int leftWall, rightWall;
    public LJRAND2 pieceSet = LJRAND2._4BLK;
    public LJRAND randomizer = LJRAND.PURE;
    public LJROT rotationSystem;
    public int garbageRandomness;  // 64: change garbageX in 1/4 of rows; 255: change all
    public LJTS tSpinAlgo = LJTS.OFF;  // 0: off, 1: TNT, 2: TDS
    public LJGRAV clearGravity;
    public LJGLUING gluing;  // 0: off; 1: square
    public LJSCORE scoreStyle;
    public LJDROP dropScoreStyle;
    public int maxUpwardKicks;
    public LJHOLD holdStyle;
    public byte bottomBlocks;
    public byte reloaded;  // 0: played through; 1: reloaded from saved state

    public String toString() {
        return state.toString();
    }

/*
    */
/**
     * Blanks a playfield and prepares it for a new game.
     */
/*
    void newGame() {

        // Clear playfield
        for (int y = 0; y < LJ_PF_HT; y++) {
            for (int x = 0; x < LJ_PF_WID; x++) {
                b[y][x] = 0;
            }
        }

        for (int y = 0; y < LJ_MAX_LINES_PER_PIECE; ++y) {
            nLineClears[y] = 0;
        }

        if (holdStyle == LJHOLD.TNT) {
            LJRandom.initRandomize(this);
            holdPiece = LJRandom.randomize(this);
        } else {
            holdPiece = LJP.NONE;  // sentinel for no piece in hold box
        }

        // Generate pieces
        LJRandom.initRandomize(this);
        for (int i = 0; i < LJ_NEXT_PIECES; i++) {
            newPiece(this, false);
        }
        clearedLines = new LJBits();
        nPieces = 0;
        state = LJState.NEW_PIECE;
        stateTime = 1;
        garbage = 0;
        outGarbage = 0;
        score = 0;
        gameTime = 0;
        activeTime = 0;
        lines = 0;
        alreadyHeld = false;
        chain = false;
        theta = 0;
        nLinesThisPiece = 0;
        canRotate = true;
        speed.entryDelay = 0;
        garbageRandomness = 64;
        reloaded = 0;

        garbageX = (int) ljRand(this) % (rightWall - leftWall)
                + leftWall;
    }
*/

}
